package cn.tiga._02_oneway;

import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.common.message.Message;

import java.nio.charset.StandardCharsets;

public class Producer {

     public static void main(String[] args) throws Exception {
         //获取producer对象
         DefaultMQProducer producer = new DefaultMQProducer("oneway-producer-Group");
         //nameserver链接
         producer.setNamesrvAddr("localhost:9876");
         //启动
         producer.start();
         //创建消息对象，设置消息
         Message message = new Message("oneway","hello","我在源码打林然".getBytes(StandardCharsets.UTF_8));
         producer.sendOneway(message);

         //关闭
         producer.shutdown();

    }
}
